package com.qfedu.zf.app.controller;

import cn.hutool.core.convert.NumberWithFormat;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qfedu.zf.app.service.UserFeign;
import com.qfedu.zf.common.config.SystemConfig;
import com.qfedu.zf.common.param.Listings;
import com.qfedu.zf.common.param.UserAdd;
import com.qfedu.zf.common.param.UserLogin;
import com.qfedu.zf.common.utils.JwtUtil;
import com.qfedu.zf.common.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * --- 天道酬勤 ---
 *
 * @author FanShuhu
 * @date 2024/6/6
 * @desc -- 代码敲烂 月薪过万--
 */

@Api("用户模块接口")
@RestController
@RequestMapping("/api/user")
public class UserController {


    @Autowired
    UserFeign userFeign;

    @RequestMapping("/listingUser")
    public R listingUser(@RequestParam Map<String,Object> map){
        return userFeign.listingUser(map);
    }

    @ApiOperation("用户注册")
    @RequestMapping("/register")
    public R register(@RequestBody UserAdd userAdd) {
        return userFeign.register(userAdd);
    }

    @ApiOperation("用户密码登录")
    @RequestMapping("/loginpass")
    public R loginpass(@RequestBody UserLogin userLogin) {
        return userFeign.loginPass(userLogin);
    }


    @ApiOperation("用户验证码登录")
    @RequestMapping("/logincode")
    public R logincode(@RequestBody UserLogin userLogin) {
        return userFeign.loginCode(userLogin);
    }

    @ApiOperation("用户退出")
    @RequestMapping("/logout")
    public R logout() {
        return userFeign.logout();
    }

    @ApiOperation("通过用户id查询用户")
    @RequestMapping(value = "/selectById",method = RequestMethod.GET)
    public R selectById(){
        return userFeign.selectById();
    }

    @ApiOperation("修改用户昵称")
    @RequestMapping(value = "/editNickname",method = RequestMethod.GET)
    public R editNickname(@RequestParam("nickname") String nickname){
        return userFeign.editNickname(nickname);
    }
    @ApiOperation("修改用户手机号")
    @RequestMapping(value = "/editPhone",method = RequestMethod.GET)
    public R editPhone(@RequestParam("code") String code,@RequestParam("phone") String phone){
        return userFeign.editPhone(code,phone);
    }
    @ApiOperation("修改用户头像")
    @RequestMapping(value = "/editAvatar",method = RequestMethod.GET)
    public R editAvatar(@RequestParam("url") String url){
        return userFeign.editAvatar(url);
    }

    @ApiOperation("上传房源")
    @RequestMapping(value = "/posting",method = RequestMethod.POST)
    public R addListing(@RequestBody Listings listing){
        return userFeign.addListing(listing);
    }

    @ApiOperation("房源列表")
    @RequestMapping(value = "/listing")
    public R listing(@RequestParam("id") String id){
        return userFeign.listing(id);
    }
    @ApiOperation("用户列表")
    @RequestMapping("/list")
    public R selectUserList(){
        return userFeign.selectUserList();
    }
    @RequestMapping(value = "/listingDelete")
    public R listingDelete(@RequestParam("id") String id){
        return userFeign.listingDelete(id);
    }

    @ApiOperation("优惠券列表")
    @RequestMapping("/coupon/list")
    public R selectList(){
        return userFeign.selectList();
    }

    @ApiOperation("新增优惠券列表")
    @RequestMapping("/couponAdd/list")
    public R selectCouponAddList(){
        return userFeign.selectCouponAddList();
    }

    @ApiOperation("优惠券详情")
    @RequestMapping(value = "/coupon/selectById")
    public R selectByCouponId(@RequestParam("id") Integer id){
        return userFeign.selectByCouponId(id);
    }

    @RequestMapping(value = "/coupon/add")
    public R couponAdd(@RequestParam("id") Integer id){
        return userFeign.couponAdd(id);
    }
    @ApiOperation("举报列表")
    @RequestMapping("/report/list")
    public R selectByReportList(){
        return userFeign.selectByReportList();
    }

    @ApiOperation("被举报列表")
    @RequestMapping("/beReport/list")
    public R beReport(){
        return userFeign.beReport();
    }

    @RequestMapping("/browse/list")
    public R selectBrowseList(@RequestParam("id") Integer id){
        return userFeign.selectBrowseList(id);
    }
}
